<?php

class Application_Form_Post extends Application_Form_InlineForm {

    public function init() {
    	
    	$this->setAttrib("id", "formpost");
    	
    	$idpost = new Zend_Form_Element_Hidden('idpost',array(
    			'decorators' => $this->getElementDecoratorHidden()
    	));
    	
    	$actionpost = new Zend_Form_Element_Hidden('actionpost',array(
    			'decorators' => $this->getElementDecoratorHidden()
    	));
		
        $titrepost = new Zend_Form_Element_Text('titrepost', array(
                    'label' => 'Titre :',
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'validators' => array(
                        array('NotEmpty', true),
						array('StringLength', true, array('max'=>50))
                    ),
                    'decorators' => $this->getElementDecorators()
                ));
				
		$descriptionpost = new Zend_Form_Element_Textarea('descriptionpost', array(
                    'label' => 'Description :',
                    'required' => true,
                    'filters' => array('StringTrim'),
                    'validators' => array(
                        array('NotEmpty', true),
						array('StringLength', true, array('max'=>500))
                    ),
                    'decorators' => $this->getElementDecorators()
                ));
		$descriptionpost->setAttrib('ROWS', '6');
		
		$langueliste = new Zend_Form_Element_Select('langue', array(
                    'label' => 'Langue :',
                    'required' => true,
                    'validators' => array('NotEmpty'),
                    'decorators' => $this->getElementDecorators()
                ));
				
			$langues = new Application_Model_Langue();
			$langues = $langues->fetchAlldata();
			$i=0;
			foreach($langues as $langue)
			{
				$langueliste->addMultiOption($langue['LANGUE_ID'],$langue['LANGUE_LIBELLE']);
				$i=$i+1;
			}	   
		
		
		$photo = new Zend_Form_Element_Hidden('photo',array(
				'decorators' => $this->getElementDecoratorHidden()
		));
		
		$extension = new Zend_Form_Element_Hidden('extension',array(
				'decorators' => $this->getElementDecoratorHidden()
		));
		
		$uploadphoto =  new Zend_Form_Element_Text('uploadphoto', array(
				'required' => true,
				'filters' => array('StringTrim'),
				'validators' => array(
						array('NotEmpty', true),
						array('StringLength', true, array('max'=>50))
				),
				'decorators' => $this->getElementDecorators(),
				'name' =>'file_upload'
		));
		
        $this->addElements(array($idpost, $actionpost, $langueliste, $titrepost,$descriptionpost, $uploadphoto, $photo, $extension));
    }
}
